Completed
Push — master ( 1719ac...509a65 )
by Jeroen De
10s
created

fee.js ➔ createFeeValidationDispatcher   A

Complexity

Conditions 1
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 1
nc 2
nop 2
1
'use strict';
2
3
/**
4
 *
5
 * @module redux_validation
6
 */
7
8
var objectAssign = require( 'object-assign' ),
9
	ValidationDispatcher = require( './base' ),
10
	Actions = require( '../actions' ),
11
	_ = require( 'underscore' ),
12
13
	/**
14
	 *
15
	 * @param {FeeValidator} validator
16
	 * @param {Object} initialValues Initial form state. Only the keys and values from fieldNames will be used
17
	 * @return {ValidationDispatcher}
18
	 */
19
	createFeeValidationDispatcher = function ( validator,  initialValues ) {
20
		var fieldNames = [ 'amount', 'paymentIntervalInMonths', 'addressType' ];
21
22
		return objectAssign( Object.create( ValidationDispatcher ), {
23
			validationFunction: validator.validate.bind( validator ),
24
			actionCreationFunction: Actions.newFinishPaymentDataValidationAction,
25
			fields: fieldNames,
26
			previousFieldValues: _.pick( initialValues || {}, fieldNames )
27
		} );
28
	};
29
30
module.exports = createFeeValidationDispatcher;
31
32